var _set = require("./../../API/set.js");
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo:app.globalData.userInfo,
    order_info:[],
    menus:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoadFun:function(){
    this.setData({
      userInfo:app.globalData.userInfo
    });
    this.getMenus();
    this.getUserInfo();
  },
  onLoad: function (options) {
    
  },
  getUserInfo:function(){
    var self = this;
    (0, _set.getUserInfo)().then(function(t) {
        self.setData({
          userInfo:t.data,
          order_info:t.data.order_info
        })
        wx.setStorage({
          key:"userInfo",
          data:t.data
        });
        app.globalData.userInfo = t.data;
        
    }).catch(function(t) {
      return app.Tips({
          title: t
      });
  });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },
  getMenus:function(){
    var self = this;
    (0, _set.getMenus)().then(function(t) {
        self.setData({
          menus: t.data,
        });
    }).catch(function(t) {
      return app.Tips({
          title: t
      });
  });
  },

  toPage:function(e){
    console.log(e.currentTarget.dataset.type)
    if(e.currentTarget.dataset.type=='order'){
      wx.switchTab({
        url: '/pages/order/order',
      })
    }else if(e.currentTarget.dataset.type=='account'){
      wx.navigateTo({
        url: '/home/pages/escort_center/index',
      })
    }else if(e.currentTarget.dataset.type=='escort_center'){
      wx.navigateTo({
        url: '/home/pages/my_task/index',
      })
    }else if(e.currentTarget.dataset.type=='apply_escort'){
      wx.navigateTo({
        url: '/home/pages/escort_join/escort_join',
      })
    }else if(e.currentTarget.dataset.type=='report'){
      wx.navigateTo({
        url: '/home/pages/report/report',
      })
    }else if(e.currentTarget.dataset.type=='setting'){
      wx.navigateTo({
        url: '/home/pages/set/set',
      })
    }else if(e.currentTarget.dataset.type=='leader_center'){
       wx.navigateTo({
        url: '/home/pages/head/head',
      })
    }
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.getMenus();
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})